﻿using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace Library.WebControls.SimpleCombobox {
	[ToolboxItem(false)]
	[DesignTimeVisible(false)]
	public class SpComboboxItemTemplate : HtmlGenericControl, IDataItemContainer {
		internal SpComboboxItemTemplate()
			: base("div") {
			Attributes["class"] = "spexcbMenuItem";
		}
		public bool IsSelected {
			get {
				return Attributes["class"] == "spexcbMenuItemActive";
			}
			set {
				Attributes.Remove("class");
				if (value) {
					Attributes["class"] = "spexcbMenuItemActive";
				} else {
					Attributes["class"] = "spexcbMenuItem";
				}
			}
		}

		public object DataItem { get; internal set; }

		public int DataItemIndex { get; internal set; }

		public int DisplayIndex { get; internal set; }

		public string Value {
			get {
				return Attributes["_spexcomboboxkey_"];
			}
			set { Attributes["_spexcomboboxkey_"] = value; }
		}
	
		public string Text {
			get {
				return Attributes["_spexcomboboxtext_"];
			}
			set {
				Attributes["_spexcomboboxtext_"] = value;
				InnerText = value;
			}

		}
	}
}
